Skip to content

Add a reusable OpenTofu workflow, with drift - #26

Merged
benbirt merged 1 commit into
mainfrom
reusable-tofu
Nov 29, 2026
Merged

benbirt merged 1 commit into
mainfrom
reusable-tofu

Conversation

@benbirt

@benbirt benbirt commented Nov 29, 2026

Copy link
Copy Markdown
Owner

Step 6, first part: one OpenTofu workflow for every repository with tofu targets, so each gets plan, apply and a daily drift check the same way.

  • tofu.yml (new, reusable). Inputs: target (required), check (a target to run first, e.g. eavesbard's PostHog query check) and plan_dependabot. Secrets: CLOUDFLARE_API_TOKEN (state) and, optionally, ADMIN_TOKEN and POSTHOG_API_KEY for the providers.

    Caller's event What runs
    pull_request plan, no state lock
    push / workflow_dispatch on main apply, waits up to 15 min for the lock
    schedule drift plan with -detailed-exitcode; on drift, comments on or opens the issue "Drift: differs from its configuration" and fails; when clean, closes it

    The drift logic is the same as drift.yaml's, tested end to end on Saturday. Issues are now titled per target, so a repository with two roots (eavesbard) gets one issue each.

  • settings.yaml calls it for //github:github (plan_dependabot: false), on the same paths plus tofu.yml, and gains the daily 06:43 schedule. drift.yaml is deleted.

This pull request's own Settings check is the first test: it runs the new tofu.yml from this branch and should plan "No changes". After merging, I'll dispatch Settings on main (an apply with no changes) and let the schedule run the drift path.

Next

Callers for benbirt.io (//infra:infra) and eavesbard (//dns:dns, //posthog:posthog with its check), replacing their own workflows. They will pin tofu.yml by commit with a release tag, so Dependabot moves the pin and the bump is planned in each repository before it merges. I'll tag a release once this merges.

The comments and README were written by Neon.

🤖 Generated with Claude Code

tofu.yml plans a tf_deploy target on pull requests, applies it on main
and checks it for drift on a schedule, opening a drift issue and failing
when it differs. The Settings workflow becomes its first caller, with
the daily drift check that drift.yaml ran, so drift.yaml goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@benbirt
benbirt merged commit 70400b5 into main Nov 29, 2026
2 checks passed
@benbirt
benbirt deleted the reusable-tofu branch November 29, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant